//
//  LRXBringingHearView.m
//  路人侠
//
//  Created by zhangxulong on 3/14/16.
//  Copyright © 2016 zhangxulong. All rights reserved.
//

#import "LRXBringingHearView.h"
#import "zxlCircleView.h"
@implementation LRXBringingHearView
- (void)layoutBringingView
{
   
    
    UIImageView * backImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"BringingHeadBack"]];
    backImage.frame =CGRectMake(0, 0, MainScreenW, self.frame.size.height);
    [self addSubview:backImage];
    
    UILabel * remainText = [[UILabel alloc]init];
    remainText.text = @"您的配送时间";
    remainText.textColor = [UIColor colorWithRed:162 green:195 blue:248];
    remainText.font = [UIFont systemFontOfSize:25 * hScale];
    [remainText sizeToFit];
    remainText.center = CGPointMake(MainScreenW * 0.5, 70 * hScale);
    [self addSubview:remainText];
    
    UIView * lineView = [[UIView alloc]init];
    lineView.backgroundColor = mainColor;
    lineView.bounds = CGRectMake(0, 0, 26 * wScale, 2 * hScale);
    lineView.center = CGPointMake(MainScreenW * 0.5, CGRectGetMaxY(remainText.frame)+ 46 * hScale);
    
    
    NSRange timeRange = {10,6};
    CGFloat timeY = CGRectGetMaxY(remainText.frame) + 28 * hScale;
    CGFloat timeW = 80 * wScale;
    UILabel * stTimeLabel = [[UILabel alloc]init];
    stTimeLabel.textAlignment = NSTextAlignmentCenter;
    
    stTimeLabel.text = [self.stTimeText substringWithRange:timeRange];
    stTimeLabel.textColor = mainColor;
    stTimeLabel.font = [UIFont systemFontOfSize:30 * hScale];
    CGFloat stTimeX = CGRectGetMinX(lineView.frame) - timeW;
    
    stTimeLabel.frame = CGRectMake(stTimeX,timeY , timeW, 34 * hScale);
    [stTimeLabel sizeToFit];
    
    UILabel * endTimeLabel = [[UILabel alloc]init];
    endTimeLabel.textAlignment = NSTextAlignmentCenter;
    endTimeLabel.font = stTimeLabel.font;
    endTimeLabel.text = [self.endTimeText substringWithRange:timeRange];
    endTimeLabel.textColor = stTimeLabel.textColor;
    CGFloat endTimeX = CGRectGetMaxX(lineView.frame) + 0 * wScale;
    endTimeLabel.frame = CGRectMake(endTimeX, timeY, timeW, 34 * hScale);
    [endTimeLabel sizeToFit];
    
    
    CGFloat stAddrLabelX = 128 * wScale;
    CGFloat stAddrLabelY = CGRectGetMaxY(stTimeLabel.frame) + 40 * hScale;
    UILabel * stAddrLabel = [[UILabel alloc]init];
    stAddrLabel.text = self.stAddrText;
    stAddrLabel.font = [UIFont systemFontOfSize:26 * hScale];
    stAddrLabel.frame = CGRectMake(stAddrLabelX, stAddrLabelY, 0, 0);
    [stAddrLabel sizeToFit];
    
    
    CGFloat endAddrLabelY = CGRectGetMaxY(stAddrLabel.frame) + 28 * hScale;
    UILabel * endAddrLabel = [[UILabel alloc]init];
    endAddrLabel.text = self.endAddrText;
    endAddrLabel.font = stAddrLabel.font;
    endAddrLabel.frame = CGRectMake(stAddrLabelX, endAddrLabelY, 0, 0);
    [endAddrLabel sizeToFit];
    
    
    
    
    
    CGFloat stSpotCenterX = CGRectGetMinX(stAddrLabel.frame) - 24 * wScale;
    zxlCircleView * stSpot = [[zxlCircleView alloc]init];
    stSpot.imageName = @"stSpot";
    stSpot.backgroundColor = [UIColor clearColor];
    zxlCircleView * endSpot = [[zxlCircleView alloc]init];
    endSpot.imageName = @"endSpot";
    endSpot.backgroundColor = [UIColor clearColor];
    stSpot.frame = CGRectMake(0,0, 17 * hScale, 15 * hScale);
    stSpot.center = CGPointMake(stSpotCenterX, stAddrLabel.center.y);
    endSpot.frame = CGRectMake(0, 0, 17 * hScale, 15 * hScale);
    endSpot.center = CGPointMake(stSpotCenterX, endAddrLabel.center.y);
    
    
    UIButton * stSendBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    stSendBtn.backgroundColor = mainColor;
    [stSendBtn setTitle:@"开始派送" forState:UIControlStateNormal];
    [stSendBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    stSendBtn.frame = CGRectMake(0, 0, 260 * wScale, 60 * hScale);
    stSendBtn.layer.cornerRadius = 10* hScale;
    CGFloat stSendBtnCenterY = CGRectGetMaxY(endAddrLabel.frame) + 70 * hScale;
    stSendBtn.center = CGPointMake(self.center.x, stSendBtnCenterY);
    [stSendBtn addTarget:self action:@selector(pushDistribution) forControlEvents:UIControlEventTouchUpInside];
    
    [self addSubview:stSendBtn];
    [self addSubview:stSpot];
    [self addSubview:endSpot];
    [self addSubview:stAddrLabel];
    [self addSubview:endAddrLabel];
    [self addSubview:lineView];
    [self addSubview:endTimeLabel];
    [self addSubview:stTimeLabel];
    
    
}
- (void)pushDistribution
{
    if ([self.LRXBringingHeadDelegate respondsToSelector:@selector(pushDistributionController)])
    {
        [self.LRXBringingHeadDelegate pushDistributionController];
    }
}
@end
